@extends('admin.base')
@section('title','消息通知')
@section('header','消息通知')
@section('content')
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <span class="layui-breadcrumb" lay-separator=">>">
                <a class="layui-btn-sm" href="{{url('admin/information/index')}}" style="cursor:pointer;" ><cite>消息列表</cite></a>;
            </span>
        </div>
    </fieldset>
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form method="get">
                    <div class="layui-card-header ">
                        <div class="layui-form " style="display: flex;">
                            <p class="">关键字：</p>
                            <div class="layui-inline sousuo">
                                <div class="layui-input-inline">
                                    <input type="text" name="keywords" class="layui-input" id="" placeholder="请输入用户ID"
                                           value="{{$request->keywords}}">
                                </div>
                            </div>
                            <!--搜索框-->
                            <div class="layui-inline sousuo">
                                <div class="layui-input-inline">
                                    <input type="text" name="title" class="layui-input" id="" placeholder="请输入标题"
                                           value="{{$request->title}}">
                                </div>
                            </div>
                            <button type="submit" class="layui-btn ok">确定</button>
                        </div>
                    </div>
                </form>
                <div class="layui-card-body">
                    <p style="float: left;margin-bottom: 20px">
                        <a href="/admin/information/create" class="layui-btn layui-btn-success layui-btn">发送消息</a>
                    </p>
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>用户ID</th>
                            <th>用户账号</th>
                            <th>标题</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @forelse($news as $vo)
                            <tr>
                                <td>{{$vo->id}}</td>
                                <td>{{$vo->uid}}</td>
                                <td>{{$vo->username}}</td>
                                <td>{{$vo->title}}</td>
                                <td>{{$vo->created_at}}</td>
                                <td>
                                    <a href="/admin/information/detail?id={{$vo->id}}"
                                       class="layui-btn layui-btn-sm">详细</a>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="15">暂无内容</td>
                            </tr>
                        @endforelse
                        </tbody>
                    </table>
                    {{$news->appends(Request::all())->links()}}
                </div>
            </div>
        </div>
    </div>
@endsection
@push('js')
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });

        function change_state(id, value, msg) {
            event.preventDefault();
            layer.confirm(msg, {
                btn: ['确认', '取消'] //按钮
            }, function () {
                window.location.href = '/ot_admin/notice/change_state/' + id + '?value=' + value;

            })
        }

        function del(id, msg) {
            event.preventDefault();
            layer.confirm(msg, {
                btn: ['确认', '取消'] //按钮
            }, function () {
                window.location.href = '/ot_admin/notice/del/' + id;

            })
        }

        function sort(id, num) {
            layer.prompt({
                formType: 3,
                value: num,
                title: '修改排序'
            }, function (value, index, elem) {
                var index = layer.load();
                $.post("/ot_admin/notice/update_sort", {
                    id: id,
                    sort: value,
                    _token: "{{csrf_token()}}"
                }, function (data) {
                    layer.close(index);
                    layer.msg(data.msg);
                    if (data.code == 1) {
                        location.reload();
                    }

                })
            });
        }

    </script>
@endpush
